﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL.Model.Repositories;

namespace BLL.Model.Voucher
{
    public class BankBookContra : Contra
    {
        //public TransactionInCheque ChequeInfo;

        public BankBookContra(IRecordRepository recordRepository) : base(recordRepository)
        {
        }

        public override string LedgerType
        {
            get { return "BankBook"; }
        }

        public override double Debit
        {
            get
            {
                if (string.IsNullOrWhiteSpace(ContraType)) throw ContraTypeNull();
                return ContraType.Equals(CashToBank, StringComparison.CurrentCultureIgnoreCase) ? Amount : 0;
            }
        }

        public override double Credit
        {
            get
            {
                if (string.IsNullOrWhiteSpace(ContraType)) throw ContraTypeNull();
                return ContraType.Equals(CashToBank, StringComparison.CurrentCultureIgnoreCase) ? 0 : Amount;
            }
        }

        public override bool Save()
        {
            return RecordRepository.InsertBankBookRow(this);
        }
    }
}
